package cn.nohan.funplay.module.member.mongo.controller;

import cn.nohan.funplay.module.member.mongo.annotation.ResponseResult;
import cn.nohan.funplay.module.member.mongo.service.notify.SystemMessage;
import cn.nohan.funplay.module.member.mongo.service.notify.SystemMessageService;
import cn.nohan.funplay.module.member.mongo.service.notify.message.CommonMessage;
import cn.nohan.funplay.module.member.mongo.service.notify.message.Message;
import cn.nohan.funplay.module.member.mongo.service.notify.message.PaymentMessage;
import com.mongoplus.model.PageResult;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

/**
 * @author caozhipeng
 * @date 2025/8/13
 */
@RequestMapping("/systemMessage")
@RestController
@ResponseResult
public class SystemMessageController {

    @Autowired
    private  SystemMessageService systemMessageService;

    @PostMapping("/send")
    public void sendMessage(@RequestBody SystemMessage<PaymentMessage> systemMessage) {
        systemMessageService.sendMessage(systemMessage);
    }



    @PostMapping("/send2")
    public void sendMessage2() {
        systemMessageService.sendMessage();
    }

    @PostMapping("/send5")
    public void sendMessage5() {
        systemMessageService.sendMessage5();
    }


    @GetMapping("/get")
    public SystemMessage<? extends Message> getMessage(@RequestParam("id") String id){
        return systemMessageService.getMessage(id);
    }

    @GetMapping("/get2")
    public Document getMessage2(@RequestParam("id") String id){
        return systemMessageService.getMessage2(id);
    }

    @GetMapping("/get3")
    public SystemMessage getMessage3(@RequestParam("id") String id){
        return systemMessageService.getMessage3(id);
    }

    @GetMapping("/getPage")
    public PageResult<SystemMessage> getMessagePage(@RequestParam(value = "pageNo",required = false,defaultValue = "1") Integer pageNo,
                                                    @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize,
                                                    @RequestParam(value = "messageType",required = false) Integer messageType){
        return systemMessageService.getMessagePage(pageNo,pageSize,messageType);
    }
}
